package com.gxa.service.commlife.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.commlife.BusinessManagementDto;
import com.gxa.entity.commlife.BusinessManagement;
import com.gxa.mapper.commlife.BusinessManagementMapper;
import com.gxa.service.commlife.BusinessManagementService;
import org.apache.commons.collections.map.HashedMap;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-12 11:18:00
 */
@Service
public class BusinessManagementServiceImpl extends ServiceImpl<BusinessManagementMapper, BusinessManagement> implements BusinessManagementService {

    @Autowired
    private BusinessManagementMapper businessManagementMapper;
    @Override
    public void addBusinessManagement(BusinessManagement businessManagement) {
      this.businessManagementMapper.addBusinessManagement(businessManagement);
    }

    @Override
    public Map<String, Object> queryList(Integer pageNum, Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        Page<BusinessManagement> page = PageHelper.startPage(pageNum,pageSize);
        List<BusinessManagement> businessManagementList = this.businessManagementMapper.queryList();
        PageInfo<BusinessManagement> pageInfo = new PageInfo<>(businessManagementList);
        map.put("pageInfo",pageInfo);
        return map;
    }

    @Override
    public BusinessManagementDto queryById(Integer id) {
        BusinessManagementDto businessManagementDto = this.businessManagementMapper.queryById(id);
        return businessManagementDto;
    }

    @Override
    public void updateBusinessManagement(BusinessManagement businessManagement) {
        this.businessManagementMapper.updateBusinessManagement(businessManagement);
    }

    @Override
    public Map<String, Object> queryListBySearch(BusinessManagement businessManagement,Integer pageNum, Integer pageSize) {
        Map<String,Object> map = new HashedMap();
        Page<BusinessManagement> page = PageHelper.startPage(pageNum,pageSize);
        List<BusinessManagement> businessManagementList = this.businessManagementMapper.queryListBySearch(businessManagement);
        PageInfo<BusinessManagement> pageInfo = new PageInfo<>(businessManagementList);
        map.put("pageInfo",pageInfo);
        return map;
    }

    @Override
    public void deleteBusinessManagement(Integer id) {
           this.businessManagementMapper.deleteBusinessManagement(id);
    }
}
